﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Windows.Threading;

namespace TouchExplorer.Controls
{
    /// <summary>
    /// Interaction logic for TouchFileDisplayTiles.xaml
    /// </summary>
    public partial class TouchFileDisplayTiles : Border
    {
        public TouchFileDisplayTiles()
        {
            InitializeComponent();
            Loaded += (sender, arg) =>
            {
                var file = DataContext as TouchFile;
                Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
                {
                    ImgElement.Source = file.BigImage;
                    System.Windows.Forms.Application.DoEvents();
                }));
            };
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var file = DataContext as TouchFile;
            if (file != null)
            {
                Process.Start(file.FullPath);
            }
        }
    }
}
